import java.util.Scanner;
public class GuessNumber {
    public static void main(String[] args) {
        while (true){
            int answer = (int)(Math.random() * 100) +1 ;
            Scanner scan = new Scanner(System.in);
            int time = 0;
            int guess = 0;

            while (time < 7){
                System.out.print("请输入一个1-100之间得数字：");
                guess = scan.nextInt();
                time = time + 1;

                if (guess < answer){
                    System.out.println("小了！");
                }else if (guess > answer){
                    System.out.println("大了！");
                }else {
                    System.out.println("恭喜你猜对了！");
                    break;
                }
            }
            if (time == 7 && answer != guess){
                System.out.println("可惜啦！次数用完啦！");
            }
            System.out.println("再来一轮吗？（y/n）：");
            String choice = scan.next();
            if (choice.equalsIgnoreCase("y")){
                break;
            }
        }
        }

}
